package com.xuyiwei.mayi.service;

import com.xuyiwei.mayi.dao.UserDao;
import com.xuyiwei.mayi.utils.TransactionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionStatus;

/**
 * Created by xuyiwei on 2019/4/18.
 */
@Service
public class UserService {
//    @Autowired
//    private UserDao userDao;
//
//    @Autowired
//    private TransactionUtils transactionUtils;
//    public void add() {
//        TransactionStatus transactionStatus = transactionUtils.begin();
//        try{
//            userDao.add("lisi", 18);
//            int i=1/0;//可能会发生异常
//            userDao.add("yushengjun", 19);
//            transactionUtils.commit(transactionStatus);
//        }catch (Exception e){
//            transactionUtils.rollback(transactionStatus);
//        }
//    }

    public void add1() {
        System.out.println("执行了添加方法");
    }

}
